/////////////////////////////////////////////////////////////////////////////////////////////
// Filename: WindowsClass.h
// (c) Dave Ottley, 2012. All rights reserved.
/////////////////////////////////////////////////////////////////////////////////////////////
#ifndef WINDOWSCLASS_H
#define WINDOWSCLASS_H

///////////////////////////
//		INCLUDES
///////////////////////////
#include <windows.h>

///////////////////////////
//		MY INCLUDES
///////////////////////////
#include "StateMachine.h"

class WindowsClass
{
public:
	inline static WindowsClass * GetInstance() { static WindowsClass theOne; return &theOne; }
	bool Initialize(HINSTANCE hInstance, int nCmdShow);
	void Shutdown() { WindowsClass::~WindowsClass(); } //Force a compile error if Shutdown() is not called

	//Getters
	const HWND GetHwnd() const { return mhWnd; }
	const HINSTANCE GetHInstance() const { return mhInstance; }
	const int GetScreenWidth() const { return mScreenWidth; }
	const int GetScreenHeight() const { return mScreenHeight; } 

	//StateMachine related functions
	StateMachine<WindowsClass> * GetFSM() const { return mStateMachine; }
	bool HandleMessage(const Telegram& msg) { return mStateMachine->HandleMessage(msg); }

private:
	//SINGLETON
	WindowsClass();
	~WindowsClass() { delete mStateMachine; mStateMachine = 0;}
	WindowsClass(const WindowsClass&);
	WindowsClass& operator=(const WindowsClass& rhs);

public:
	LRESULT CALLBACK MessageHandler(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);

private:
	HWND mhWnd;
	HINSTANCE mhInstance;
	int mnCmdShow;
	int mScreenWidth;
	int mScreenHeight;
	bool mMinimized;
	bool mMaximized;
	bool mResizing;
	uint32_t mID;
	StateMachine<WindowsClass> * mStateMachine;

};

#ifndef WindowsCls
#define WindowsCls WindowsClass::GetInstance()
#endif

#endif // WINDOWSCLASS_H